package com.qingzhou.web.controller.tool;

import com.qingzhou.common.utils.FileUtil;
import com.qingzhou.framework.config.FileConfig;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.annotation.Post;
import org.noear.solon.core.handle.Result;
import org.noear.solon.core.handle.UploadedFile;

/**
 * 文件 操作处理
 * @author xm
 */
@Controller
@Mapping("tool/file")
public class FileController {

    @Inject
    FileConfig fileConfig;

    /**
     * 单文件上传
     */
    @Post
    @Mapping("upload")
    public Result<String> upload(UploadedFile file) {
        return Result.succeed(FileUtil.upload(file, fileConfig.getMaxSize(), fileConfig.getFileType(), fileConfig.getSavePath(), fileConfig.getRequestPrefix()));
    }

}
